package xworker.gluon.glisten.control;

import com.gluonhq.charm.glisten.control.CardCell;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.control.IndexedCellActions;

public class CardCellActions {
    public static void init(CardCell<Object> cell, Thing thing, ActionContext actionContext){
        IndexedCellActions.init(cell, thing, actionContext);
    }

    public static CardCell<Object> create(ActionContext actionContext){
        Thing self = actionContext.getObject("self");
        CardCell<Object> cell = new CardCell<Object>(){
            @Override
            public void updateItem(Object item, boolean empty) {
                super.updateItem(item, empty);

                self.doAction("updateItem", actionContext, "cell", this, "item", item, "empty", empty);
            }
        };

        actionContext.peek().put("parent", cell);
        for(Thing child : self.getChilds()){
            child.doAction("create", actionContext);
        }

        actionContext.g().put(self.getMetadata().getName(), cell);
        return cell;
    }
}
